<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<title>Document</title>
		<script src="./scripts/vue.js"></script>
		<script src="./scripts/vue-router_3.0.2.js"></script>
	</head>
	<body>
		<div id="app">
			<router-link to="/shoplist">商品列表</router-link>
			<router-link to="/register">注册</router-link>

			<router-view></router-view>
		</div>

		<script>
			var ShopList = {
				template: `
			       <div>
			         <h2>商品详情</h2>
			         <hr />

			         <router-link to="/shoplist/shopA">商品A</router-link>
			         <router-link to="/shoplist/shopB">商品B</router-link>
			         <router-link to="/shoplist/shopC">商品C</router-link>

			      <router-view></router-view>
			       </div>
			     `
			}
			var Register = {
				template: `<h2>注册</h2>`
			}

			var ShopA = {
				template: `<h4>商品A</h4>`
			}
			var ShopB = {
				template: `<h4>商品B</h4>`
			}
			var ShopC = {
				template: `<h4>商品C</h4>`
			}

			var router = new VueRouter({
				routes: [
					{ path: '/', redirect: '/register' },
					{
						path: '/shoplist',
						name: 'ShopList',
						component: ShopList,
						children: [
							{ path: 'shopA', component: ShopA },
							{ path: 'shopB', component: ShopB },
							{ path: 'shopC', component: ShopC }
						]
					},
					{ path: '/register', name: 'Register', component: Register }
				]
			})
			var vm = new Vue({
				el: '#app',
				data: {},
				router
			})
		</script>
	</body>
</html>
